<!-- 钱包地址绑定 -->
<template>
  <div id="c-walletBind">
    <van-popup v-model="show" position="bottom" :style="{ height: '40%' }" :close-on-click-overlay="false" round>
      <van-nav-bar title="绑定钱包地址" />
      <div style="padding: 40px 20px 0;">
        <van-button type="danger" block round v-if="!walletSite" @click="getCurrentBTYAddress">获取钱包地址</van-button>
        <van-cell-group inset v-if="walletSite" :border="false">
          <van-cell title="钱包地址" :value="walletSite" :border="false"/>
          <van-button type="primary" block round @click="bindBTYAddress">确认绑定</van-button>
        </van-cell-group>
        <van-button style="margin-top: 10px;" block round  @click="setCloneWalletBind">暂不绑定</van-button>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: true,
      walletSite: ""
    };
  },
  methods: {
    getCurrentBTYAddress() {
      let _this = this;
      jsBridge.getCurrentBTYAddress({},(v)=>{
        _this.$toast(v);
        _this.walletSite = v;
      });
      // jsBridge.call("getCurrentBTYAddress", function(v) {
      //   _this.$toast(v);
      //   _this.walletSite = v;
      // });
    },
    async bindBTYAddress() {
      let { result, msg } = await $http.get("plugin.love-speed-pool.frontend.wallet-site.edit-info",{site: this.walletSite});
      this.$toast(msg);
      if (result == 1) this.show = false;
    },
    setCloneWalletBind(){
      localStorage.setItem("isCloneWalletBind",true);
      location.reload();
    }
  }
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped></style>
